package com.project.service;

import java.util.List;

import com.project.dao.GoalDao;
import com.project.entity.Goal;
import com.project.util.DateUtil;
import com.project.util.PKUtil;

public class GoalService {

	GoalDao dao = new GoalDao();
	
	public List<Goal> findGoalByProjectid(String projectid){
		
		return dao.findGoalByProjectid(projectid);
	}
	
	public void Save(String cont,String name,String userid,String projectid){
		
		Goal goal = new Goal();
		 
		goal.setCont(cont);
		goal.setCreatetime(DateUtil.getNow());
		goal.setId(PKUtil.getId());
		goal.setName(name);
		goal.setProjectid(projectid);
		goal.setUserid(userid);
		 
		dao.save(goal);
	}
	
	public Goal findByGoalid(String id) {
		return dao.findByGoalid(id);
	}
	
	public boolean UpdateGoal(String id,String cont,String name) {
		
		 Goal goal = new Goal();
		 goal.setId(id);
		 goal.setCont(cont);
		 goal.setName(name);
		 
		return dao.updateGoal(goal);
	}
	
	public int countRate(String goalid) {		
		return dao.countRate(goalid);
	}
}
